\documentclass[a4paper, 12pt]{article}

\usepackage[margin=1.5cm]{geometry}
\usepackage{fancyvrb}
\usepackage{enumitem}
\usepackage{listings}
\usepackage[colorlinks, urlcolor=blue]{hyperref}
\usepackage{tocloft}

\setlength{\parskip}{1.5ex}
\setlength{\parindent}{0pt}
\setlength{\cftbeforesecskip}{0.5ex}

\lstset{
    frame=single, aboveskip=0.5cm, belowskip=0.2cm, basicstyle=\ttfamily,
    columns=flexible, framesep=0pt, framextopmargin=3pt, framexbottommargin=3pt,
    framexleftmargin=-1pt
}

\title{Troubleshooting Arch Linux}
\author{Chen Rushan\\chenrsster@gmail.com}
\date{2009.08.06 16:30}

\begin{document}
\maketitle

\begingroup
\hypersetup{linkcolor=blue}
\tableofcontents
\endgroup

\newpage

\section{Failed to create filesystem during installation}

    Sometimes, it's possible that creating filesystem fails during installation
    due to various mysterious reasons. To deal with such situation, exit
    installation, and create filesystem using tools like \verb=mkfs= before you
    run \verb=/arch/setup=, so that only mounting is needed when installing
    system(it may also require you to reboot before running \verb=/arch/setup=).

    It's also a good practice to do disk partition and filesystem creation
    before installation.
    
\section{Add a new user}

    By default, after installation complete, there's only \verb=root= user on
    the system, to add a new user, say \verb=chenrs=, run:

    \begin{lstlisting}[gobble=3]
    adduser chenrs
    \end{lstlisting}

    And then if you want to give this user the right to run sudo, add the
    following line to file {\em /etc/sudoers}:

    \begin{lstlisting}[gobble=3]
    chenrs  ALL=(ALL) ALL
    \end{lstlisting}

    It's recommended that you edit this file through command \verb=visudo=,
    instead of using \verb=sudo vi= directly.

\section{Bash completion}

    To make bash completion even smarter like completion for \verb=sudo=,
    completing only directory names after \verb=cd= command, install package
    {\em bash-completion}

    But simply installing the package will only change the behavior of login
    shell, for those non-login shells, nothing will happen unless you add the
    following lines to {\em \$HOME/.bashrc}:
    
    \begin{lstlisting}[gobble=3]
    if [ -f /etc/bash_completion ]; then
            . /etc/bash_completion
    fi
    \end{lstlisting}

\section{mount problem}
   
    When trying to run the following command as root:
    \begin{lstlisting}[gobble=3]
    mount -t cifs //192.168.1.2/video /mnt
    \end{lstlisting}

    \noindent I got such error:
    \begin{lstlisting}[gobble=3]
    mount error(13): Permission denied
    \end{lstlisting}

    Then I run command like: (still as root user)
    \begin{lstlisting}[gobble=3]
    mount -t cifs //192.168.1.2/video /mnt -o username=guest
    \end{lstlisting}
    \noindent everything is OK. (Of course, the samba server has specified 
    \verb/guest ok = yes/)
 
    But the wired thing is, when I run \verb=mount= as a regular user like:
    \begin{lstlisting}[gobble=3]
    sudo mount -t cifs //192.168.1.2/video /mnt
    \end{lstlisting}
    It's OK too, no more \verb/-o username=guest/.
 
    I don't know why.
 
    NOTE: \verb=-t cifs= is actually not necessary here.

\section{Starting X freeze my system}

    Just installing {\em Xorg} is insufficient to start \verb=X= correctly, you
    still need to configure it, so that it knows about your graphics card,
    mouse and keyboard. (Note that there's no \verb=xorg.conf= after
    installation)

    One of the possible solutions is to install {\em hal}, add it to 
    {\em DAEMONS} array of {\em /etc/rc.conf}.

    After installation complete, start X, for example, by running:

    \begin{lstlisting}[gobble=3]
    startx
    \end{lstlisting}

    If you managed to start X now, a file named {\em /var/log/Xorg.0.log} will
    be generated, and copy text between the following two lines like:
    \begin{lstlisting}[gobble=3]
    (==) --- Start of built-in configuration ---
    \end{lstlisting}
    and
    \begin{lstlisting}[gobble=3]
    (==) --- End of built-in configuration ---
    \end{lstlisting}
    to your {\em xorg.conf}.

    It seems necessary to create a {\em xorg.conf}, although you are able to
    start X successfully without it, but in order to take full advantage of
    your nvidia or ati card, it's needed.

    Now install {\em nvidia}, run:
    \begin{lstlisting}[gobble=3]
    sudo pacman -Sy nvidia
    \end{lstlisting}

    After installation complete, make change to {\em /etc/X11/xorg.conf} as
    follows:

    Add a new section \verb=Module=:
    \begin{lstlisting}[gobble=3]
    Section "Module"
            Load "glx"
    EndSection
    \end{lstlisting}

    Change all the occurrences of 
    \begin{lstlisting}[gobble=3]
    Driver "nv"
    \end{lstlisting}
    or
    \begin{lstlisting}[gobble=3]
    Driver "vesa"
    \end{lstlisting}
    to
    \begin{lstlisting}[gobble=3]
    Driver "nvidia"
    \end{lstlisting}
 
\section{no sound}
 
    To let your computer speak, follow these steps:
    \begin{enumerate}
        \item Install \verb=alsa-lib= and \verb=alsa-utils=.
        \item Add yourself to \verb=audio= group by running:
            \begin{lstlisting}[gobble=11]
            sudo gpasswd -a chenrs audio
            \end{lstlisting}
        \item Add \verb=alsa= to the DAEMONS array in \verb=/etc/rc.conf=.
    \end{enumerate}
 
\section{urxvt scrollbar}
    Since now I can't abandon scrollbar, so I need to choose the style of the
    scrollbar that I like most, and I find it's the \verb=plain= style, so add
    the following line to \verb=$HOME/.Xdefaults=:
    \begin{lstlisting}[gobble=3]
    URxvt.scrollstyle: plain
    \end{lstlisting}
 
    Sometimes we may want to scroll upward to see some previous output even 
    when currently running program is still outputting, in urxvt, this is not 
    allowed by default, but it can be changed by adding the following line to
    \verb=$HOME/.Xdefaults=:
    \begin{lstlisting}[gobble=3]
    URxvt.scrollTtyOutput: False
    \end{lstlisting}
 
    But this setting simultaneously disable a useful feature, that is if we now
    have scrolled upward far away from the bottom and we want to input a 
    command, what we hope is urxvt itself jumping to the bottom quickly and
    automatically, instead of letting us ourself scroll downward to the bottom.
    To accomplish this, add the following line to \verb=.Xdefaults=:
    \begin{lstlisting}[gobble=3]
    URxvt.scrollTtyKeypress: True
    \end{lstlisting}
 
\section{SCIM Chinese input}

    \begin{lstlisting}[gobble=3]
    SCIM is now deprecated, ibus is a better input method.
    \end{lstlisting}

    Add the following lines to \verb=$HOME/.xinitrc=:

    \begin{lstlisting}[gobble=3]
    export XMODIFIERS="@im=SCIM"
    export GTK_IM_MODULE="scim"
    export QT_IM_MODULE="scim"
    scim -d &
    \end{lstlisting}
 
\section{ATI driver for my IBM laptop}

    Seems there's no way to install the driver that fit my ATI card completely
    according to the arch linux wiki.
 
\section{Ctrl+Alt+Backspace issue}

    I haven't solved this problem yet.
 
\section{pacman error}

    When downloading using \verb=pacman -S=, if you got error message like:
    \begin{lstlisting}[gobble=3]
    error: failed retrieving file 'irssi-0.8.13-1-i686.pkg.tar.gz' from <mirror>
    \end{lstlisting}
 
    Then chances are that your local package database is not up-to-date, 
    running:
    \begin{lstlisting}[gobble=3]
    pacman -Syy
    \end{lstlisting}
    to force update your package database.
    
\section{sshd problem}
 
    Unlike other distros you've used before, by default, nobody is allowed to
    connect to your machine after you start your ssh server, to allow everyone
    to connect to you, add the following line to \verb=/etc/hosts.allow=:
    \begin{lstlisting}[gobble=3]
    sshd: ALL
    \end{lstlisting}
 
    You can also give only a few people permission to login, for more 
    information, you can see the arch wiki for ssh.
 
\section{samba server problem}
 
    I got the following error when I want to connect to this machine:

    \begin{lstlisting}[gobble=3]
    mount error(13): Permission denied
    \end{lstlisting}

    The command I run on client side is:

    \begin{lstlisting}[gobble=3]
    sudo mount -t cifs //192.168.1.3/home /mnt/
    \end{lstlisting}
 
    I haven't found a way to solve this yet.
 
    I got previous error when I log on to this machine as a guest, but I think
    it's just not supposed to be, cuz I've already added \verb/"guest ok = yes"/
    into \verb=/etc/samba/smb.conf=, so I think login as guest is OK.
 
    Login as a normal samba user is OK, the command on client side is:
    \begin{lstlisting}[gobble=3]
    sudo mount -t cifs //192.168.1.3/home /mnt/ -o username=chenrs
    \end{lstlisting}
 
\section{VirtualBox issue}
 
    To successfully run VirtualBox, you need to do the following things:

    \begin{enumerate}
        \item Add yourself to group \verb=vboxusers=:
            \begin{lstlisting}[gobble=11]
            sudo gpasswd -a chenrs vboxusers
            \end{lstlisting}
 
        \item Reboot your system
 
        \item Load module \verb=vboxdrv= with:
            \begin{lstlisting}[gobble=11]
            sudo modprobe vboxdrv
            \end{lstlisting}
 
            To let make this module be automatically loaded during system
            startup, add \verb=vboxdrv= to the \verb=MODULES= array of 
            \verb=/etc/rc.conf=.
        
            If this module is not loaded, you'll get the following warning:

            \begin{lstlisting}[gobble=11]
            WARNING: The vboxdrv kernel module is not loaded. Either there is no module
                      available for the current kernel (2.6.30-ARCH) or it failed to
                      load. Please recompile the kernel module and install it by
                  
                      sudo /etc/init.d/vboxdrv setup
                              
                      You will not be able to start VMs until this problem is fixed.
            \end{lstlisting}
 
            The command presented in the warning doesn't work, since arch uses
            the BSD-style init, there's no such directory as 
            \verb=/etc/init.d/=.
 
        \item Install \verb=qt= if you haven't got it installed yet, or you'll 
            get the following error:

            \begin{lstlisting}[gobble=11]
            VirtualBox: supR3HardenedMainGetTrustedMain:
            dlopen("/usr/lib/virtualbox/VirtualBox.so",) failed: libQtCore.so.4: 
            cannot open shared object file: No such file or directory
            \end{lstlisting}

    \end{enumerate}

\section{Autologin with mingetty}

    Autologin can be accomplished through {\em mingetty}, which is located in
    AUR, the whole process of installing {\em mingetty} is:

    \begin{enumerate}
        \item Go to \href{http://aur.archlinux.org/}{http://aur.archlinux.org/},
            type {\texttt mingetty} in \verb=Search Criteria=.

        \item Click link \verb=Tarball= to download the necessary archive.

        \item Extract the archive, and \verb=cd= to the generated directory.

        \item Run command \verb=makepkg -s=, after it's done, a file whose name
            is postfixed by \verb=.pkg.tar.gz= is generated.

        \item Run command:
            \begin{lstlisting}[gobble=11]
            sudo pacman -U <mingetty-blah-blah>.pkg.tar.gz
            \end{lstlisting}
    \end{enumerate}

    Now {\em mingetty} is installed, the next step is to modify {\em
    /etc/inittab}, change the line look somewhat like this:
    \begin{lstlisting}[gobble=3]
    c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
    \end{lstlisting}
    to be:
    \begin{lstlisting}[gobble=3]
    c1:2345:respawn:/sbin/mingetty --autologin chenrs tty1 linux
    \end{lstlisting}

    Note that you should leave out the \verb=-8= option, it can be recognized by
    {\em mingetty}.

    Now restart you computer.

\section{Autostart X at boot}

    I choose to use command \verb=startx= to start X window, since it's
    relatively more lightweight than using other method like \verb=gdm=, add
    the following lines to {\em \$HOME/.bash\_profile}:

    \begin{lstlisting}[gobble=3]
    if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
        startx
        logout
    fi
    \end{lstlisting}

    Now X will automatically start when you log into the shell. Furthermore,
    your user will be logged out when you kill X, next time you login, X will
    start automatically.

\section{Change system time}

    To change system time, run the following command in order:

    \begin{lstlisting}[gobble=3]
    sudo hwclock --set --date='12/01/09 08:56:40'
    sudo hwclock -s
    \end{lstlisting}

    The 1st command set the hardware date, and the 2nd command set the system
    date to be the same as the hardware date. (Note that don't add
    \verb=--localtime= option to the 1st command)

\section{Something having to do with Gnome}
 
    I'm now enjoying working with openbox, it's so sweet, maybe I'll never
    use those cumbersome desktop environments like Gnome and KDE any more.
 
    \subsection{key press problem}
 
    When I keep holding one key down under X, it just behaves as if I press it
    and release it instantly, for example, in vim, if I keep holding \verb=j=,
    the cursor is expected to keep moving downward, whereas, in my case, it 
    just move downward one step, and stop, why?
    
    Shit, finally the answer is found, this is actually an issue of Gnome, not
    X.  Open \\\verb=System -> Preferences -> Keyboard=, under the 
    \verb=General= tab, you'll find an option related to whether key press is
    repeated when the key is held down and its delay and speed.
    
    BTW, the above behavior affect this config file:\\
    \verb=/home/chenrs/.gconf/desktop/gnome/peripherals/keyboard/%gconf.xml=\\
    You can find what you've configured here.
 
    \subsection{Configure gnome to login automatically} 
    
    Open \verb=System -> Administration -> Login Window=, Go to \verb=Security=
    tab, enable the option \\\verb="Enable Automatic Login"=, and enter your
    username below.

    \section{\LaTeX{} related issues}

    By default, texlive doesn't come with {\em enumitem.sty}, you need to
    install package {\em texlive-latexextra} to get it.

    There are many {\em .sty} file residing in directory {\em
    /usr/share/texmf-dist/tex/latex/}

\section{Install s2disk}

    Since I'm not able to access the git server shown in PKGBUILD of uswsusp
    package, I failed to install uswsusp-git package from AUR and need to
    install it manually. In fact, installing manually is quite easy, you just
    follow exactly those steps in PKGBUILD (of course, some steps might fail,
    since the package you download may be a little different with the one
    downloaded automatically by makepkg. But most of the time, this does't
    matter).

    \begin{enumerate}[itemsep=0pt]
        \item Download uswsusp from \url{http://suspend.sourceforge.net}
        \item Run {\bf configure \&\& make \&\& make install} as PKGBUILD shows
        \item Install {\bf uresume-hook} and {\bf uresume-install}
        \item Modify /etc/suspend.conf to enable compression
        \item Modify /etc/mkinitcpio.conf to add {\bf uresume} to HOOKS list, Note
            that it should placed immediately before {\bf filesystems}
        \item Run {\bf mkinitcpio -p linux}
        \item Done
    \end{enumerate}

    {\bf uswsusp} works in the way that you the user run {\bf s2disk} to suspend
    the whole system to the swap partition and after you press the power button,
    {\bf resume} will be called during boot time to load system from swap to
    memory.

\end{document}
